package com.lab.service.impl;

import com.lab.dao.ConsumableDao;
import com.lab.pojo.Consumable;
import com.lab.service.ConsumableService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("consumableService")
public class ConsumableServiceImp implements ConsumableService {
    @Resource
    ConsumableDao consumableDao;
    public List<Consumable> allConsumables() {
        return consumableDao.allConsumables();
    }

    public void saveConsumable(Consumable consumable) {
        if (consumable.getCid()!=null){
            //修改
            consumableDao.updateConsumable(consumable);
        }else {
            //增加
            consumableDao.addConsumable(consumable);
        }
    }

    public void deleteConsumable(Long[] cid) {
        consumableDao.deleteConsumable(cid);
    }

    public Consumable findConsumableById(Long cid) {
        return consumableDao.findConsumableById(cid);
    }
}
